<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
	<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
		<!DOCTYPE >
		<html>

		<head>
			<base href="<%=basePath%>">
			<title>新生儿疾病筛查</title>
			<meta charset="utf-8" />
			<meta http-equiv="X-UA-Compatible" content="IE=edge" />
			<meta name="viewport" content="width=device-width, initial-scale=1" />
			<link rel="icon" href="favicon.ico" />
			<link href="static/manage-sys/css/bootstrap.min.css" rel="stylesheet" />
			<link href="static/manage-sys/css/font-awesome.min.css" rel="stylesheet" />
			<link href="static/manage-sys/css/default.css" rel="stylesheet" type="text/css" />
			<!-- 自动补全-->
			<link rel="stylesheet" type="text/css" href="static/manage-sys/add-sample/css/autoComplete.css">
			<!-- 耳聋基因页面样式-->
			<link rel="stylesheet" type="text/css" href="static/manage-sys/add-sample/css/deaf.css">

			<script src="static/manage-sys/js/jquery.min.js"></script>
			<!--[if lt IE 9]>
			<script src="js/bootstrap/html5shiv.min.js"></script>
			<script src="js/bootstrap/respond.min.js"></script>
			<![endif]-->
			<!--页面加载进度条-->
			<link href="static/manage-sys/css/pace/dataurl.css" rel="stylesheet" />
			<script src="static/manage-sys/js/pace/pace.min.js"></script>
			<script src="static/manage-sys/js/jquery.scrolltopcontrol/scrolltopcontrol.js" type="text/javascript"></script>
			<script src="static/manage-sys/js/jquery.extend.js" type="text/javascript"></script>
			<script src="static/manage-sys/js/default.js" type="text/javascript"></script>

			<link rel="stylesheet" type="text/css" href="static/manage-sys/add-sample/easyui/themes/ui-cupertino/easyui.css" />
			<link rel="stylesheet" type="text/css" href="static/manage-sys/add-sample/easyui/themes/icon.css" />
			<link rel="stylesheet" type="text/css" href="static/manage-sys/add-sample/css/icon.css" />
			<link rel="stylesheet" type="text/css" href="static/manage-sys/add-sample/css/uims.css" />
			<link rel="stylesheet" type="text/css" href="static/manage-sys/add-sample/css/temp.css" />

			<script type="text/javascript" src="static/manage-sys/add-sample/easyui/jquery.easyui.min.js"></script>
			<script type="text/javascript" src="static/manage-sys/add-sample/easyui/locale/easyui-lang-zh_CN.js"></script>

			<script src="static/manage-sys/js/bootstrap/bootstrap.min.js"></script>
			<script src="static/manage-sys/js/bootstrap/bootstrap-table.min.js"></script>
			<script src="static/manage-sys/js/bootstrap/bootstrap-table-zh-CN.min.js"></script>

			<script type="text/javascript" src="static/manage-sys/add-sample/js/dataGridCellTip.js"></script>
			<script type="text/javascript" src="static/manage-sys/add-sample/js/validate.js"></script>
			<script type="text/javascript" src="static/manage-sys/add-sample/js/json2.js"></script>

			<script type="text/javascript" src="static/manage-sys/add-sample/js/sampleCommon.js"></script>
			<script type="text/javascript" src="static/manage-sys/add-sample/js/template.js"></script>

			<!-- artTemplate 模板引擎 -->
			<script src="static/manage-sys/js/template-web.js" type="text/javascript"></script>

			<!-- 设置送检单位 -->
			<script src="static/manage-sys/js/set-customer.js" type="text/javascript"></script>
			<!-- 下拉菜单 -->
			<link href="static/manage-sys/css/bootstrap-select/bootstrap-select.min.css" rel="stylesheet" />
			<script src="static/manage-sys/js/bootstrap-select/bootstrap-select.min.js"></script>
			<script src="static/manage-sys/js/bootstrap-select/i18n/defaults-zh_CN.min.js"></script>
			<script src="static/manage-sys/js/bootstrap-select/bootstrap-select-custom.js"></script>
			<!-- 省市区 -->
			<script type="text/javascript" src="static/manage-sys/js/cj-pcd/cj-pcd-1.0.1.min.js"></script>
			<!-- 自动补全-->
			<script type="text/javascript" src="static/manage-sys/add-sample/js/autoComplete.js"></script>
			<!-- 加载民族信息-->
			<script type="text/javascript">
				var nationalities = [
					'阿昌族','白族','保安族','布朗族','布依族','朝鲜族','达斡尔族','傣族','德昂族','东乡族','侗族','独龙族','俄罗斯族','鄂伦春族',
					'鄂温克族','高山族','仡佬族','哈尼族','哈萨克族','汉族','赫哲族','回族','基诺族','京族','景颇族','柯尔克孜族','拉祜族','黎族',
					'傈僳族','珞巴族','满族','毛南族','门巴族','蒙古族','苗族','仫佬族','纳西族','怒族','普米族','羌族','撒拉族','畲族',
					'水族','塔吉克族','土家族','土族','佤族','维吾尔族','乌孜别克族','锡伯族','瑶族','彝族','裕固族','藏族','壮族'
				];

				$(document).ready(function(){
					$('#search').autocomplete({
						hints: nationalities,//指定资源
						width: 160,
						height: 25
					});
				});
			</script>

			<style>
				.coupon-box {
					height: 120px;
					text-align: center;
					line-height: 120px;
					border: 1px dashed #2e85b8;
					font-size: 24px;
					color: #cecece;
					margin: 30px 0 10px 0;
					cursor: pointer;
					background: #fff;
				}

				.coupon-item {
					width: 80%;
					box-shadow: 2px 2px 5px #f2f2f2, -2px -2px 5px #f2f2f2;
					border-bottom: 1px solid #eee;
					display: flex;
					margin: 10px auto;
					flex-direction: row;
				}

				.coupon-item .btn {
					display: block;
					margin: 10px;
					width: 60px;
					padding: 0;
					height: 28px;
					line-height: 28px;
					text-align: center;
					background: #45b4f5;
					color: #fff;
					/* outline: none; */
					border-color: transparent;
				}

				.coupon-item .content-wrapper {
					flex: 1;
					padding: 10px;
					line-height: 24px;
				}

				.coupon-item .content-wrapper .name {
					font-size: 14px;
					font-weight: 400;
					color: rgba(0, 0, 0, 0.85);
				}

				.coupon-item .content-wrapper .desc {
					font-size: 12px;
					margin-top: 4px;
					color: rgba(0, 0, 0, 0.55);
				}

				.search-box input {
					display: inline-block;
					flex: 1;
					height: 33px;
					line-height: 33px;
					padding-left: 6px;
					/* border-color: transparent; */
					outline: none;
					box-shadow: none;
					/* border: 0; */
					border: 1px solid #7bcdf8;
				}

				.search-box button {
					width: 80px;
					background: #7bcdf8;
					outline: none;
					border: 1px solid #7bcdf8;
					color: #fff;
				}

				.empty-coupon {
					text-align: center;
					line-height: 42px;
					height: 42px;
					font-size: 18px;
					color: rgba(0, 0, 0, 0.45);
				}

				.no-coupon {
					height: 33px;
					line-height: 33px;
					text-align: center;
					margin: 10px 0;
					border: 1px dashed #7bcdf8;
					cursor: pointer;
				}
			</style>
		</head>

		<body>
			<!--我是主要内容-->
			<div class="container">
				<div class="content">
					<div class="coupon-box" onclick="chooseCoupon()">
						选择免费券
					</div>
					<table class="second-table t-group">
						<tbody>
							<tr class="blue-tr">
								<td class="t-group-title">受检者信息</td>
							</tr>
							<tr>
								<td class="droppable column3">
									<span class="field t-group-item">
										<span class="required">*</span>
										<i class="t-field-id" data-value="isCharge"></i>
										<i class="t-name">缴费类型</i>：
										<select id="isCharge"  validate="required" disabled="disabled">
											<option value="2" class="t-value" data-name="收费" data-value="2">收费</option>
											<option value="1" class="t-value" data-name="免费" data-value="1">免费</option>
										</select>
									</span>
									<span class="field t-group-item">
										<span class="required">*</span>
										<i class="t-field-id" data-value="motherName"></i>
										<i class="t-name">母亲姓名</i>：
										<input type="text" id="motherName" validate="required" class="t-value">
									</span>
									<span class="field t-group-item">
										<span class="required">*</span>
										<i class="t-field-id" data-value="idCard"></i>
										<i class="t-type" data-value="idCard"></i>
										<i class="t-name">身份证号</i>：
										<input type="text" id="idCard" validate="required,idCard" class="t-value">
									</span>
								</td>
							</tr>
							<tr>
								<td class="droppable column3">
									<span class="field t-group-item">
										<span class="required">*</span>
										<i class="t-field-id" data-value="motherAge"></i>
										<i class="t-type" data-value="number"></i>
										<i class="t-name">母亲年龄</i>：
										<input type="text" id="motherAge" validate="required" class="t-value">
									</span>
									<span class="field t-group-item">
										<span class="required">*</span>
										<i class="t-field-id" data-value="motherPhoneNum"></i>
										<i class="t-type" data-value="phoneNum"></i>
										<i class="t-name t-require">母亲电话</i>：
										<input validate='required,phoneNum' type="text" id="motherPhoneNum" class="t-value">
									</span>
									<span class="field t-group-item">
										<span class="required">*</span>
										<i class="t-field-id" data-value="samplePhoneNum"></i>
										<i class="t-type" data-value="phoneNum"></i>
										<i class="t-name">其他联系电话</i>：
										<input validate='required,phoneNum' type="text" id="samplePhoneNum" class="t-value">
									</span>
								</td>
							</tr>
							<tr>
								<td class="droppable column3">
									<span class="field t-group-item">
										<span class="required">*</span>
										<i class="t-field-id" data-value="sampleSex"></i>
										<i class="t-name">新生儿性别</i>：
										<select id="sampleSex"  validate="required">
											<option value="" class="t-value" data-name="" data-value="">请选择</option>
											<option value="1" class="t-value" data-name="男" data-value="1">男</option>
											<option value="2" class="t-value" data-name="女" data-value="2">女</option>
										</select>
									</span>
									<span class="field t-group-item" id="sampleNameDiv" style="display: none">
									<span class="required">*</span>
									<i class="t-field-id" data-value="sampleName"></i>
									<i class="t-name t-require">新生儿姓名</i>：
									<select id="sampleName" validate="required" style="width: 149.2px;">
										<option value="" class="t-value" data-name="" data-value="">请选择</option>
										<option value="" class="t-value" data-name="" data-value="" id="sampleNameA"></option>
										<option value="" class="t-value" data-name="" data-value="" id="sampleNameB"></option>
										<option value="" class="t-value" data-name="" data-value="" id="sampleNameC"></option>
									</select>
								</span>
									<span class="field t-group-item">
										<span class="required">*</span>
										<i class="t-field-id" data-value="birthDate"></i>
										<i class="t-name">新生儿出生日期</i>：
										<%--<input type="date" id="birthDate" validate="required" class="t-value">--%>
										<input class="easyui-datetimebox" name="birthday" id="birthDate"
											   data-options="required:true,showSeconds:false" style="width:150px;background: #fff;border-color: #dfdfdf">
									</span>
								</td>
							</tr>
							<tr>
								<td class="droppable column3">
									<span class="field t-group-item">
									<span class="required">*</span>
									<i class="t-field-id" data-value="nativePlace"></i>
									<i class="t-type" data-value="nativePlace"></i>
									<i class="t-name">籍贯</i>：
									<input type="hidden" id="nativePlace1" style="width: 90px;">
                                     <i class="t-name">省</i>
                                     <div style="display:inline-block;">
                                        <select id="province" onchange="addressChange('#province')" class="selectpicker form-control" data-live-search="true" data-max-options="1">
                                            <option value="">请选择</option>
                                        </select>
                                    </div>
									<input type="hidden" id="nativePlace2" style="width: 90px;">
                                     <i class="t-name">市</i>
                                    <div style="display:inline-block;">
                                        <select id="city" onchange="addressChange('#city')" class="selectpicker form-control" data-live-search="true" data-max-options="1">
                                            <option value="">请选择</option>
                                        </select>
                                    </div>
								</span>
									<span class="field t-group-item">
										<span class="required">*</span>
										<i class="t-field-id" data-value="nationaltily"></i>
										<i class="t-name">民族</i>：
										<input type="text" id="nationaltily" validate='required' class="t-value">
									</span>
								</td>
							</tr>
						</tbody>
					</table>
					<table class="second-table t-group">
						<tbody>
							<tr class="blue-tr">
								<td class="t-group-title">临床信息</td>
							</tr>
							<tr>
								<td class="droppable">
									<span class="field t-group-item">
										<i class="t-field-id" data-value="clinicalManifestation"></i>
										<i class="t-name">临床表现（如有临床表现，请详细描述）</i>：
										<input type="text" id="clinicalManifestation" style="width: 180px;" class="t-value">
									</span>
									<span class="field t-group-item">
										<span class="required">*</span>
										<i class="t-type" data-value="split"></i>
										<i class="t-field-id" data-value="gestationalWeeks"></i>
										<i class="t-name t-require">分娩时孕周</i>：
										<span class="t-group-item-split">
											<i class="t-field-id" data-value="gestationalWeeks1"></i>
											<i class="t-hint" data-value=""></i>
											<i class="t-type" data-value="number"></i>
											<i class="t-name t-require" style="display: none;">分娩时孕周</i>
											<input type="text" id="gestationalWeeks1" validate="required" style="width: 80px;">周
										</span>
										<span class="t-group-item-split">
											<i class="t-hint" data-value=""></i>
											<i class="t-type" data-value="number"></i>
											<i class="t-field-id" data-value="gestationalWeeks2"></i>
											<input type="text" id="gestationalWeeks2" style="width: 80px;">天
										</span>
										<input type="text" id="gestationalWeeks" style="opacity: 0;border:0px;"/>
									</span>
								</td>
							</tr>
							<tr>
								<td class="droppable">
									<span class="field t-group-item">
										<span class="required">*</span>
										<i class="t-field-id" data-value="bodyWeight"></i>
										<i class="t-name">出生时体重</i>：
										<input type="text" id="bodyWeight" validate="required" style="width: 131.6px;" class="t-value">
										<i class="t-unit" style="display:none;">g</i>
									</span>
									<span>g；&nbsp;&nbsp;</span>
									<span class="field t-group-item">
										<i class="t-field-id" data-value="bodyHeight"></i>
										<i class="t-name">身高（出生时体长）</i>：
										<input type="text" id="bodyHeight" style="width: 106.4px;" class="t-value">
										<i class="t-unit">cm</i>
									</span>
								</td>

							</tr>
							<tr>
								<td class="droppable">
									<span class="field t-group-item">
										<span class="required">*</span>
										<i class="t-field-id" data-value="suckler72"></i>
										<i class="t-name">是否充分哺乳（6~8次）</i>：
										<select id="suckler72" validate="required">
											<option value="" class="t-value" data-name="请选择" data-value="">请选择</option>
											<option value="1" class="t-value" data-name="是" data-value="1">是</option>
											<option value="0" class="t-value" data-name="否" data-value="0">否</option>
										</select>
									</span>
									<span class="field t-group-item">
										<i class="t-field-id" data-value="deliveryMode"></i>
										<i class="t-name">分娩方式</i>：
										<select id="deliveryMode">
											<option value="" class="t-value" data-name="请选择" data-value="">请选择</option>
											<option value="0" class="t-value" data-name="平产" data-value="0">平产</option>
											<option value="1" class="t-value" data-name="剖腹产" data-value="1">剖腹产</option>
										</select>
									</span>
								</td>
							</tr>
						</tbody>
					</table>
					<table class="second-table t-group">
						<tbody>
							<tr class="blue-tr">
								<td class="t-group-title">家族信息</td>
							</tr>
							<tr>
								<td class="droppable">
									<span class="field t-group-item">
										<i class="t-field-id" data-value="familyProduce"></i>
										<i class="t-name">家族史（如果父母有家族遗传病史，请详细描述）</i>：
										<input type="text" id="familyProduce" style="width: 520px;" class="t-value">
									</span>
								</td>
							</tr>
						</tbody>
					</table>
					<table class="second-table t-group">
						<tbody>
						<tr class="blue-tr">
							<td class="t-group-title">备注</td>
						</tr>
						<tr>
							<td class="droppable">
									<span class="field t-group-item">
										<i class="t-field-id" data-value="notes"></i>
										<i class="t-name">备注</i>：
										<textarea id="notes" style="width: 520px;height: 80px;border: 1px solid #dfdfdf;margin: 20px 0;" class="t-value"></textarea>
									</span>
							</td>
						</tr>
						</tbody>
					</table>
				</div>
				<div style="width:220px; margin: 30px auto;">
					<button onclick="save();" style="width: 120px; height: 33px; border-radius: 2px; border-radius: 4px; background: rgb(23,134,184); color: #fff; outline: none; border-color: transparent;">保存</button>
				</div>
			</div>
			<!-- 模态框（Modal） -->
			<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
								&times;
							</button>
							<h4 class="modal-title" id="myModalLabel">
								免费券列表
							</h4>
						</div>
						<div class="modal-body">
							<div class="search-box" style='display:flex;flex-direction:row'>
								<input type="text" placeholder="请输入证件号码" id="coupon-kw" style="display:inline-block;flex:1">
								<button onclick="searchCoupons()">搜索</button>
							</div>
							<div class="no-coupon">
								不使用免费券
							</div>
							<div class="empty-coupon">
								没有免费券
							</div>
							<div class="coupon-list">
							</div>
						</div>
						<div class="modal-footer">
							<button type="button" class="btn btn-default" data-dismiss="modal">
								关闭
							</button>
						</div>
					</div>
					<!-- /.modal-content -->
				</div>
				<!-- /.modal -->
			</div>
			<i class="t-product-value" style="display: none;">BS0002</i>）

			<a href="#top" id="goTop">
				<i class="fa fa-angle-up fa-3x"></i>
			</a>
			<script type="text/javascript">
				var temp = object(tempAbs);
				temp.sampleInfos = [];
				temp.address = true;

				//判断当前是否是编辑功能
				var isEdit=false;
				temp.read = function(obj,bn){
					bn.setSampleInfos();

					isEdit=true;
					if (obj && obj.customerCode) {
						bn.setComboBox('customerCode', obj.customerCode);
					}
					$(".second-table .field input").each(function(){
						var id = $(this).attr('id');
						if(id && id.indexOf('sampleType_')<0){
							if($(this).hasClass('easyui-datebox')){
								bn.setDat(id);
							}else{
								var type = $(this).attr('type');
								if(type=='text' || type=='date' || type=='number'){
									bn.setVl(id);
								}
							}
						}
					});
					$(".second-table .field select").each(function(){
						var id = $(this).attr('id');
						bn.setSel(id);
					});
					if(obj.sampleType){
						var sampleTypeArr = obj.sampleType.split(',');
						$("input:checkbox[name^='sampleType_']").each(function(i){
							var id = $(this).attr('name');
							setCkArr(id,sampleTypeArr[i]);
						});
					}

					var all = {};
					$(".second-table .group-field input").each(function(){
						var id = $(this).attr('id');
						all[id.split('_')[0]] = 1;
					});

					for(var key in all){
						bn.setCkGrp(key);
					}

					//展示免费类型
					if(obj.isCharge == "" || obj.isCharge == 1){
						$('#isCharge').val("1");
					}else if(obj.isCharge == 2){
						$('#isCharge').val("2");
					}

					//展示籍贯信息
					if(obj.nativePlace){
						var sf = obj.nativePlace.substring(0,obj.nativePlace.indexOf('省')+1);
						var sq = obj.nativePlace.substring(obj.nativePlace.indexOf('省')+1,obj.nativePlace.length);
						$('#nativePlace1').val(sf);
						$('#nativePlace2').val(sq);
					}

					//身份证信息不可更改
					$("#idCard").attr("disabled","disabled");

					//展示免费券编码
					$("div.coupon-box").removeAttr("onclick").html("<span>免费券编码：</span>"+obj.couponNum);
					//$("#saveBtn").hide();
				}



				temp.save = function(bn){
					bn.getSampleInfos(temp.sampleInfos);
					// bn.getComboGrid('customerCode');
					bn.vl('sampleNum');
					$(".second-table .field input").each(function(){
						var id = $(this).attr('id');
						if(id && id.indexOf('sampleType_')<0){
							var type = $(this).attr('type');
							if($(this).hasClass('easyui-datebox')){
								bn.dat(id);
							}else{
								if(type=='text'){
									bn.vl(id);
								}else if(type=='date'){
									bn.vl(id);
								}else if(type=='number'){
									bn.vl(id);
								}
							}
						}
					});
					$(".second-table .field select").each(function(){
						var id = $(this).attr('id');
						bn.sel(id);
					});
					var sampleTypeArr = [];
					var countSampleType = {};
					$("input:checkbox[name^='sampleType_']").each(function(){
						countSampleType[$(this).attr('name')] = 1;
					});
					for(var key in countSampleType){
						var val = ckArr(key);
						if(val){
							sampleTypeArr.push(val);
						}
					}
					bn.obj.sampleType = sampleTypeArr.join(',');
					//处理单选框字段
					$(".group-field input").each(function(){
						if($(this).is(":checked")){
							var id = $(this).attr('id');
							var arr = id.split('_');
							bn.obj[arr[0]] = arr[1];
						}
					});
					if(bn.obj.nativePlace1){
						bn.obj['nativePlace'] = bn.obj.nativePlace1+'省'+bn.obj.nativePlace2+'市';
						delete bn.obj.nativePlace1;
						delete bn.obj.nativePlace2;
					}
					if(bn.obj.idCard){
						bn.obj.idCard  = bn.obj.idCard.toUpperCase();
					}
				}
				temp.validateAbs = function(m){
					var msg = '';
					if(m) msg += m;
					return msg;
				}
				//下拉列表显示省市信息
				var BASEURL = '';
				$(function (){
					if(isEdit){
						var province=$("#nativePlace1").val();
						var city=$("#nativePlace2").val();
						if((province !="" && province != null) && (city != "" && city !=null)){
							$("#province option:selected").text(province);
							$("#city option:selected").text(city);
						}else{
							resetSelect($('#province'), '', 10);
						}
					}else{
						resetSelect($('#province'), '', 10);
					}

				});

				//省市区
				function resetSelect(jq, parentId, defaultIdx) {
					var url = BASEURL+'/csfy/intf.do?method=getAddrs';
					if (parentId) {
						url = url + '&parentId=' + parentId;
					}
					var jqId = '#' + jq.attr('id');
					$.getJSON(url, function (data) {
						if (data.msg === 'success') {
							jq.empty();
							$.each(data.rows, function (i, item) {
								var option = $('<option></option>');
								option.attr('value', item['code']);
								option.text(item['name']);
								jq.append(option);
							});
							if (defaultIdx) {
								jq.get(0).selectedIndex = defaultIdx;
								//alert(defaultIdx);
							}

							if (jqId) {
								addressChange(jqId);
							}
							jq.selectpicker('refresh');

							//将选择的值放入隐藏文本框中，方便验证
							var province=$("#province option:selected").text();
							var city=$("#city option:selected").text();
							//alert(province + city);
							if(province != "" && city !=""){
								$("#nativePlace1").val(province);
								$("#nativePlace2").val(city);
							}
						}
					});
				}


				function addressChange(id) {
					var code = $(id).children('option:selected').attr('value')
					switch (id) {
						case '#province':
						{
							var defaultIdx = undefined;
							if (code == 43) {
								defaultIdx = 8;
							}
							resetSelect($('#city'), code, defaultIdx);

							break;
						}
						case '#city':
						{
							resetSelect($('#county'), code);
							$('#town').empty();
							$('#town').selectpicker('refresh');
							break;
						}

					}
				}
				//不使用优惠券
				$(".no-coupon").click(function () {
					$("#dnaMotherIdCard").removeAttr('disabled');
					$("#motherName").removeAttr('disabled');
					//收费类型
					$('#isCharge').val("2");
					$('#myModal').modal('hide');
					couponNum = '';
					$('.coupon-box').html('选择免费券');
				});

				//退出登录
				function logout() {
					$.ajax({
						url: '/csfy/dologout.do',
						method: 'POST',
						success: function (res) {
							if (JSON.parse(res).code == 200) {
								window.location.href = "/csfy/index.do"
							}
						}
					})
				}
				//使用优惠券
				var couponNum = '';

				//受检者姓名
				var sampleName = '';

				function useCoupon(num) {
					//优惠券对应的身份证号码
					var id = $("#coupon-kw").val();
					//设置优惠券对应的身份证
					$("#idCard").val(id);
					//设置身份证输入框不可编辑
					$("#idCard").attr('disabled', 'disabled');

					//收费类型
					$('#isCharge').val("1");

					//使用优惠券姓名
					$("#motherName").val(sampleName);
					$("#motherName").attr('disabled', 'disabled');

					$('#myModal').modal('hide');
					$('.coupon-box').html('免费券码：' + (num ? num : ''));

					//重置搜索列表
					$("#coupon-kw").val('');
					$(".coupon-list").html('');
					$(".empty-coupon").hide();

					couponNum = num;
				}

				//身份证号失去焦点
				$("#idCard").blur(function () {
					var id = $("#idCard").val();
					$.ajax({
						method: 'POST',
						url: '/csfy/intf.do',
						data: {
							method: 'getDetailPresonInfo',
							id
						},
						success: function (res) {
							console.log(res)
							var couponList = '';
							sampleName = res.rows.name;
							$(".coupon-list").html('');
							$(".empty-coupon").html('正在搜索...');
							if (res && res.code == 200) {
								var couponInfos = (res.rows && res.rows.couponInfos) || [];
								for(var i = 0;i < couponInfos.length;i++){
									if(couponInfos[i].productCode == "BS0002" && couponInfos[i].status == 1){
										couponNum = couponInfos[i].couponNum;
										$('#isCharge').val("1");
									}
								}
							}
						}
					});
				});
				//TODO 根据证件搜索优惠券
				function searchCoupons() {
					var id = $("#coupon-kw").val();
					if (id) {
						$.ajax({
							method: 'POST',
							url: '/csfy/intf.do',
							data: {
								method: 'getDetailPresonInfo',
								id
							},
							success: function (res) {
								console.log(res)
								var couponList = '';
								sampleName = res.rows.name;
								$(".coupon-list").html('');
								$(".empty-coupon").html('正在搜索...');
								if (res && res.code == 200) {
									var couponInfos = (res.rows && res.rows.couponInfos) || [];
									if (couponInfos.length > 0) {
										var mData = {};
										mData.rows = couponInfos;
										var html = template('coupon-list', mData);
										$(".coupon-list").html(html);
										$(".empty-coupon").hide();
									} else {
										$(".empty-coupon").html('未找到当前证件名下的免费券');
									}
								} else {
									$(".empty-coupon").html('未找到当前证件名下的免费券');
								}
							}
						});
					} else {
						$(".coupon-list").html('');
						$(".empty-coupon").show();
						$(".empty-coupon").html('没有找到免费券');
					}
				}
				//选择使用优惠券
				function chooseCoupon() {
					$('#myModal').modal('show');
				}
				//生成新生儿姓名
				$("#sampleSex").change(function () {
					if($("#sampleSex").val() == 1){
						$("#sampleNameA").text($("#motherName").val() + "大子").attr("value",$("#motherName").val() + "大子");
						$("#sampleNameB").text($("#motherName").val() + "二子").attr("value",$("#motherName").val() + "二子");
						$("#sampleNameC").text($("#motherName").val() + "三子").attr("value",$("#motherName").val() + "三子");
					}else if($("#sampleSex").val() == 2){
						$("#sampleNameA").text($("#motherName").val() + "大女").attr("value",$("#motherName").val() + "大女");
						$("#sampleNameB").text($("#motherName").val() + "二女").attr("value",$("#motherName").val() + "二女");
						$("#sampleNameC").text($("#motherName").val() + "三女").attr("value",$("#motherName").val() + "三女");
					}
					$("#sampleNameDiv").show();
				});
				$("#motherName").change(function () {
					if($("#sampleSex").val() == 1){
						$("#sampleNameA").text($("#motherName").val() + "大子").attr("value",$("#motherName").val() + "大子");
						$("#sampleNameB").text($("#motherName").val() + "二子").attr("value",$("#motherName").val() + "二子");
						$("#sampleNameC").text($("#motherName").val() + "三子").attr("value",$("#motherName").val() + "三子");
					}else if($("#sampleSex").val() == 2){
						$("#sampleNameA").text($("#motherName").val() + "大女").attr("value",$("#motherName").val() + "大女");
						$("#sampleNameB").text($("#motherName").val() + "二女").attr("value",$("#motherName").val() + "二女");
						$("#sampleNameC").text($("#motherName").val() + "三女").attr("value",$("#motherName").val() + "三女");
					}
				});
				function save(cover) {
					//获取当前页面的子页面里面的属性值
					var msg = temp.validate();
					//获取模板字段。
					var obj = temp.saveAbs();
					//报错并退出
					if (msg) {
						sysErrorShow(msg);
						return false;
					}

					if($("#samplePhoneNum").val() == $("#motherPhoneNum").val()){
						alert("母亲联系电话和其他联系电话不能相同，请重新输入！");
						return false;
					}

					//数据过滤 start
					var params = {};
					Object.keys(obj).map(key => {
						var prototype = Object.prototype.toString.call(obj[key]);
						if ('[object String]' === prototype && obj[key]) {
							params[key] = obj[key];
						}
					});
					if (couponNum) {
						params.couponNum = couponNum;
					}
					//获取省市信息
					var province=$("#nativePlace1").val();
					console.log("省" + $("#nativePlace1").val());
					var city=$("#nativePlace2").val();
					// alert(province + city);
					var nativePlaceInfo = province + city;
					var isTrueNative = confirm("确定籍贯为："+nativePlaceInfo +"？提交后无法修改，请仔细核对！");
					if(isTrueNative){
						if(province != "" && city !=""){
							params.nativePlace = province + city;
						}else{
							alert("请填写正确的籍贯信息！");
							return false;
						}
					}else {
						return false;
					}
					//校验孕周
					if($("#gestationalWeeks1").val() < 15 || $("#gestationalWeeks1").val() > 50){
						alert("请正确填写分娩时孕周！");
						return false;
					}
					//孕周
					if($("#gestationalWeeks2").val() == ""){
						params.gestationalWeeks = $("#gestationalWeeks1").val() + "/" + "0";
					}else {
						params.gestationalWeeks = $("#gestationalWeeks1").val() + "/" + $("#gestationalWeeks2").val();
					}
					//出生日期
					if($("#birthDate").datebox("getValue") != ""){
						params.birthDate = $("#birthDate").datebox("getValue");
					}else {
						alert("请选择新生儿出生日期");
						return false;
					}

					if($("#notes").val().length > 0){
						params.notes = $("#notes").val();
					}

					//设置模板文件路径，对应前端工作平台1.0的模板服务器路径
					params.fileVer = "temp/akxChildGenTest.jsp";

					params.productName = '新生儿疾病筛查';
					params.productCode = 'BS0002';

					console.dir(params);

					//数据过滤 end

					$.ajax({
						type: 'POST',
						data: {
							method: isEdit ? 'updateExportSampleBases' : 'createSampleBase',
							...params,
							sampleBaseId: isEdit ? sampleBaseId : undefined
						},
						url: '/csfy/intf.do',
						error: function (e) {
							sysErrorShow('操作失败!');
						},
						success: function (res) {
							if (res && res.code == 200) {
								alert(isEdit ? "修改送检单成功" : "保存送检单成功");
								if (!isEdit)
									window.location.href = window.location.pathname;
								else
									sessionStorage.setItem("sampleEditSuccess", "true");
							} else if (res) {
								alert(res.msg ? res.msg : "操作失败")
							}
						}
					});
				}
				//获取当前登录用户信息
				$(document).ready(function () {
					$.ajax({
						method: 'POST',
						url: '/csfy/intf.do',
						data: { method: 'getLoginUserInfo' },
						success: res => {
							if (res.code == 10086) {
								<%--window.location.href = "/csfy/index.do"--%>
								alert("请重新登录！");
							} else {
								if (res.code == 200) {
									$(".username").html(res.rows.userName);
								}
							}
						}
					})
				})
				//编辑功能进入，展示孕周信息
				$(function (){
					var gestationWeeks = $("#gestationalWeeks").val();
					var gestationalWeeks1 = gestationWeeks.substring(0,gestationWeeks.indexOf("/"));
					var gestationalWeeks2 = gestationWeeks.substring(gestationWeeks.indexOf("/")+1,gestationWeeks.length);

					$("#gestationalWeeks1").val(gestationalWeeks1);
					$("#gestationalWeeks2").val(gestationalWeeks2);
					// $("#saveBtn").hide();
				});
			</script>
			<!-- 优惠券列表渲染 -->
			<script id="coupon-list" type="text/html">
				{{each rows item i}}
					<div class="coupon-item">
						<div class="content-wrapper">
							<div class="name">{{item.couponName}}</div>
							<div class="desc">{{item.couponDesc}}</div>
						</div>
						{{if item.productCode == 'BS0002' && item.status == '1'}}
							<button class="btn btn-primary" onclick="useCoupon('{{item.couponNum}}')">使用</button>
						{{/if}}
						{{if item.productCode != 'BS0002' || ( item.productCode == 'BS0002' && item.status != '1')}}
							<button class="btn btn-disbled" disabled>不可用</button>
						{{/if}}
					</div>
				{{/each}}
			</script>
		</body>
		<style type="text/css">
			.second-table tr td input[type~="text"],
			select,
			input[type~="date"] {
				width: 160px;
			}

			.select-discribe {
				color: rgb(0, 192, 255);
			}

			.column3 .field {
				display: inline-block;
				min-width: 250px;
				text-align: left;
			}

			.column2 .field {
				width: 50%;
				float: left;
			}
		</style>

		</html>